package serialize_protocol

import "encoding/json"

type JsonSerializer struct {
}

func (j *JsonSerializer) Code() uint8 {
	return 1
}

func (j *JsonSerializer) Encode(data interface{}) ([]byte, error) {
	return json.Marshal(data)
}

func (j *JsonSerializer) Decode(bs []byte, data interface{}) error {
	return json.Unmarshal(bs, data)
}

var _ Serializer = (*JsonSerializer)(nil)
